<?php

App::uses('AppHelper', 'View/Helper');

class ProductionHelper extends AppHelper {
	
	public $helpers = array('Html');
	
	public function productsList($products) {
		$return = '';
		if(count($products)>0) {
			foreach($products as $product) {
			    $productName = $productNameSubstr = $product['name'];
			    $limit = 20;
			    if(strlen($productName)>$limit) {
			        $productNameSubstr = substr($productName, 0, $limit) . "...";
			    }
				$return .= '<p class="list-item">'.
								'<span class="price">'.
									number_format($product['ProductionProduct']['price'], 2, ",", ".").
								' = </span>'.
								'<span class="amount">' . (int)$product['ProductionProduct']['amount'] . '</span> '.
								'<span class="name"> x '.
									$this->Html->link($productNameSubstr, "javascript:void(0);", array(
									    'title'   => $productName,
									    'onclick' => 'lightBox("/proizvodi/proizvod/' . $product["id"] . '/ajax:1", 400, 300, "'.$productName.'")'
									)).
								'</span>'.
							'</p>';
			}
		}
		return $return;
	}
	
}

?>